using System;

namespace OpenLightGroup.Common
{
    /// <summary>
    /// Holds the static extension methods for the TimeSpan type.
    /// </summary>
    public static class TimeSpanExtensions
    {

   

        /// <summary>
        /// Calculates age by using now minus the offset as the start date and now as the end date.
        /// </summary>
        /// <param name="offset">The offset. Subtracted from now to get start date.</param>
        /// <returns></returns>
        public static Age ToAge(this TimeSpan offset)
        {
            DateTime endDate = DateTime.Now;

            return Age.FromTimeSpan(offset, endDate);
        }

        /// <summary>
        /// Calculates age by using <paramref name="endDate"/> minus the offset as the start date and  the <paramref name="endDate"/>.
        /// </summary>
        /// <param name="offset">The offset. Subtracted from <paramref name="endDate"/> to get start date.</param>
        /// <param name="endDate"></param>       
        /// <returns></returns>
        public static Age ToAge(this TimeSpan offset, DateTime endDate)
        {
            return Age.FromDates(endDate - offset, endDate);
        }

  


    }
}
